import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


public class UsingSpriteClass extends MIDlet {
	private Display display;
	private CowBoy cowBoy;
	private UsingSpriteClass usingSpriteClass;
	public UsingSpriteClass(){
		display = Display.getDisplay(this);
		usingSpriteClass = new UsingSpriteClass();
		try {
			cowBoy = usingSpriteClass.new CowBoy(32,48);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}
	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
		//display.setCurrent(cowBoy);
	}

	/*
	 * Create class CowBoy
	 */
	public class CowBoy extends Sprite{
		static final int WIDTH = 32;
		static final int HEIGHT = 48;
		int[] FRAME_SEQUENCE = { 3, 2, 1, 2 };
		int myInitialX;
		int myInitialY;
		public CowBoy(int frameWidth, int frameHeight) throws Exception {
			super(Image.createImage("cowboy.png"), WIDTH, HEIGHT);
			myInitialX = frameWidth;
			myInitialY = frameHeight;
			defineReferencePixel(WIDTH/2, 0);
		    setRefPixelPosition(myInitialX, myInitialY);
		    setFrameSequence(FRAME_SEQUENCE);
			// TODO Auto-generated constructor stub
		}

	}
}
